package com.ids.idtma.util;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;

import com.ids.idtma.config.MyDate;
import com.ids.idtma.config.ProjectConfig;
import com.ids.proxy.IDSApiProxyMgr;

import android.os.Environment;
import android.util.Log;

public final class LwtLog {

	@SuppressWarnings("unused")
	public static void d(String tag, String msg) {
		if (ProjectConfig.DEBUG == true) {
			Log.d(tag, msg);
			saveLog(tag,msg);
		}
	}

	private static void saveLog(String tag, String msg) {
		StringBuilder builder = new StringBuilder();
		builder.append(tag+"      的日志:    "+msg+"       "+ new MyDate().getDateEN() +"\n");
		 try {
			BufferedWriter os = new BufferedWriter(new OutputStreamWriter(                        
                    new FileOutputStream(new File("/mnt/sdcard/xiezhixian.txt"), true)));
			os.write(builder.toString());
			os.close();
		} catch (Exception e) {
		}  
           
		//IDSApiProxyMgr.getCurProxy().IDT_Log("/mnt/sdcard/xiezhixian.txt", msg);
		
	}

	private static FileOutputStream out = null;

	

	@SuppressWarnings("unused")
	public static void e(String tag, String msg) {
		if (ProjectConfig.DEBUG == true) {
			Log.d(tag, msg);
			saveLog(tag,msg);
		}
	}

	@SuppressWarnings("unused")
	public static void i(String tag, String msg) {
		if (ProjectConfig.DEBUG == true) {
			Log.i(tag, msg);
			saveLog(tag,msg);
		}
	}

	@SuppressWarnings("unused")
	public static void e(String tag, String msg, Exception exception) {
		if (ProjectConfig.DEBUG == true) {
			Log.d(tag, msg);
			saveLog(tag,msg);
		}
	}

	@SuppressWarnings("unused")
	public static void v(String tag, String msg) {
		if (ProjectConfig.DEBUG == true) {
			Log.v(tag, msg);
			saveLog(tag,msg);
		}
	}
}
